<template>
  <!-- <div> -->
    <!-- table -->
<tr >
          <td >{{id}}</td>
          <td>{{name}}</td>
          <td>{{date}}</td>
          <td>
            <button @click.prevent="onRemove(id)" >删除</button>
            <button >编辑</button>
          </td>
        </tr>
  <!-- </div> -->
</template>

<script>
import axios from 'axios'
export default {
  props: ['name', 'date', 'id'],
  data () {
    return {

    }
  },

  created () {

  },

  methods: {
    async onRemove (e) {
      try {
        const res = await axios({
          url: 'books/' + e,
          method: 'DELETE'
        })
        // this.
        console.log(res.data)
        if (res.data.status === 200) {
          alert('删除成功')
          // this.$parent.getGoods()
          this.$emit('getGoods')
        } else {
          alert('删除失败')
        }
      } catch (error) {

      }
    }
  }
}
</script>

<style scoped lang='less'>

</style>
